<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <?php include 'inc/head.php'; ?>
</head>

<body>
  <?php include 'inc/header.php'; ?>

  <div class="container">

    <table class="table table-sm table-bordered table-hover">
      <thead class="bg-light">
        <tr>
          <th>碎片名称</th>
          <th>调用代码</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <?php
        foreach ($list as $row) {
          echo '<tr><td>' . $row['c_name'] . '</td><td>' . $row['c_code'] . '</td><td><a href="' . M('admin', 'chip', 'edit', $row['id']) . '">编辑</a> <a href="' . M('admin', 'chip', 'del', $row['id']) . '" onclick="return confirm(\'确认要删除吗？\')">删除</a></td></tr>';
        }
        ?>
      </tbody>
    </table>

    <nav>
      <ul class="pagination pagination-sm justify-content-center"><?php echo $pager->show(); ?></ul>
    </nav>

    <?php
    echo form_create(
      ['action' => M('admin', 'chip', 'add')],
      [
        ['type' => 'text', 'label' => '名称', 'key' => 'c_name', 'required' => 'required'],
        ['type' => 'text', 'label' => '调用代码', 'key' => 'c_code', 'required' => 'required'],
        ['type' => 'editor', 'label' => '内容', 'key' => 'c_content'],
        ['type' => 'submit', 'label' => '提交', 'key' => 'save']
      ],
      ['碎片新增']
    );
    ?>

  </div>

  <?php include 'inc/footer.php'; ?>

</body>

</html>